//
//  AIQuestionTopTableViewCell.swift
//  AIImage
//
//  Created by deng on 2023/12/10.
//

import UIKit
import Reusable

class AIQuestionTopTableViewCell: UITableViewCell,Reusable {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupViews()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupViews()
    }
    
    let imgV = UIImageView.init()
    let nameL = UILabel.init()
    let infoL = UILabel.init()
    
    private func setupViews() {
     
        selectionStyle = .none
        backgroundColor = .clear
        
        contentView.addSubview(imgV)
        imgV.snp.makeConstraints { make in
            make.left.top.right.equalToSuperview()
            make.height.equalTo((KScreenWidth-40*DS.s)/375*240)
        }
        imgV.contentMode = .scaleAspectFill
        imgV.clipsToBounds = true
        
        nameL.font = .systemFont(ofSize: 30, weight: .semibold)
        nameL.textColor = .white
        contentView.addSubview(nameL)
        nameL.snp.makeConstraints { make in
            make.left.equalTo(20*DS.s)
            make.right.equalTo(-20*DS.s)
            make.top.equalTo(imgV.snp.bottom).offset(24*DS.s)
        }
        
        infoL.font = .systemFont(ofSize: 16, weight: .bold)
        infoL.textColor = .white
        infoL.numberOfLines = 0
        contentView.addSubview(infoL)
        infoL.snp.makeConstraints { make in
            make.left.right.equalTo(nameL)
            make.top.equalTo(nameL.snp.bottom).offset(20*DS.s)
            make.bottom.equalToSuperview().offset(-26*DS.s)
        }
    }
    
    func setupData(fatherM:AISaveModel,vo:AIModel){
        
        imgV.image = LocalMan.shared.getImage(imagePath: fatherM.imagePath ?? "")
        nameL.text = vo.name ?? ""
        infoL.text = vo.detail ?? ""
    }
}
